package vip.xiaonuo.util;

import cn.hutool.system.SystemUtil;
import vip.xiaonuo.core.file.modular.local.prop.LocalFileProperties;

public class FileUtil {

    private final LocalFileProperties localFileProperties;

    private String currentSavePath = "";

    public FileUtil(LocalFileProperties localFileProperties) {
        this.localFileProperties = localFileProperties;
        initClient();
    }

    public void initClient() {
        if (SystemUtil.getOsInfo().isWindows()) {
            String savePathWindows = localFileProperties.getLocalFileSavePathWin();
            if (!cn.hutool.core.io.FileUtil.exist(savePathWindows)) {
                cn.hutool.core.io.FileUtil.mkdir(savePathWindows);
            }
            currentSavePath = savePathWindows;
        } else {
            String savePathLinux = localFileProperties.getLocalFileSavePathLinux();
            if (!cn.hutool.core.io.FileUtil.exist(savePathLinux)) {
                cn.hutool.core.io.FileUtil.mkdir(savePathLinux);
            }
            currentSavePath = savePathLinux;
        }
    }

}
